package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zajw {
   private zoz a = null;
   private int b;
   private com.aspose.cells.a.f.zi c;
   private static final com.aspose.cells.b.c.a.za d = new com.aspose.cells.b.c.a.za(new String[]{"{BBE1A952-AA13-448e-AADC-164F8A28A991}", "{46BE6895-7355-4a93-B00E-2C351335B9C9}", "slicerCaches", "autoRecover", "crashSave", "dataExtractLoad", "repairLoad", "name", "guid", "activeSheetId", "xWindow", "yWindow", "windowWidth", "windowHeight", "mergeInterval", "personalView", "maximized", "autoUpdate", "changesSavedWin", "includeHiddenRowCol", "includePrintSettings", "minimized", "onlySync", "showFormulaBar", "showHorizontalScroll", "showVerticalScroll", "showSheetTabs", "showStatusbar", "tabRatio", "showComments", "ObjectDisplayType", "commNone", "commIndicator", "none", "placeholders", "embed", "show", "all", "noIndicator", "namespaceUri", "url"});

   zajw(zoz var1, com.aspose.cells.a.f.zi var2) {
      this.a = var1;
      this.c = var2;
   }

   void a(zcfw var1) throws Exception {
      this.r(var1);
      ArrayList var2 = null;
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if (!"xmlns".equals(var1.o()) && !"xmlns:r".equals(var1.o())) {
               if (this.a.a.b.i.h == null) {
                  var2 = new ArrayList();
                  this.a.a.b.i.h = var2;
               }

               com.aspose.cells.b.a.a.ze.a(var2, (Object)(new znm(var1.o(), var1.s())));
            }
         }
      }

      if (!var1.n()) {
         var1.d();

         while(zass.a(var1)) {
            if ("bookViews".equals(var1.p())) {
               this.o(var1);
            } else if ("sheets".equals(var1.p())) {
               this.p(var1);
            } else if ("externalReferences".equals(var1.p())) {
               this.l(var1);
            } else if ("definedNames".equals(var1.p())) {
               this.q(var1);
            } else if ("workbookPr".equals(var1.p())) {
               this.n(var1);
            } else if ("fileVersion".equals(var1.p())) {
               this.k(var1);
            } else if ("fileSharing".equals(var1.p())) {
               this.j(var1);
            } else if ("pivotCaches".equals(var1.p())) {
               this.m(var1);
            } else if ("workbookProtection".equals(var1.p())) {
               this.i(var1);
            } else if ("calcPr".equals(var1.p())) {
               this.h(var1);
            } else if ("oleSize".equals(var1.p())) {
               String var3 = var1.a("ref", (String)null);
               if (var3 != null && !"".equals(var3)) {
                  this.a.a.getWorksheets().setOleSize((CellArea)CellArea.a(var3, true));
               }

               var1.a();
            } else if ("customWorkbookViews".equals(var1.p())) {
               this.e(var1);
            } else if ("extLst".equals(var1.p())) {
               this.c(var1);
            } else if ("smartTagPr".equals(var1.p())) {
               this.f(var1);
            } else if ("smartTagTypes".equals(var1.p())) {
               this.g(var1);
            } else if ("fileRecoveryPr".equals(var1.p())) {
               this.d(var1);
            } else {
               var1.a();
            }
         }

         if (this.a.a.getWorksheets().getCount() == 0) {
            throw new CellsException(18, "File is corrupted.");
         } else {
            this.a.a.getWorksheets().setActiveSheetIndex(this.b);
         }
      }
   }

   private void c(zcfw var1) throws Exception {
      HashMap var2 = this.a.a.b.i.j;
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            String var3 = var1.a("uri");
            switch(d.a(var3)) {
            case 0:
            case 1:
               this.a(var1, var3);
               break;
            default:
               var2.put(var3, var1.u());
            }
         }

      }
   }

   private void a(zcfw var1, String var2) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            switch(d.a(var1.p())) {
            case 2:
               this.b(var1, var2);
               break;
            default:
               var1.a();
            }
         }

      }
   }

   private void b(zcfw var1, String var2) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         for(; zass.a(var1); var1.a()) {
            if ("slicerCache".equals(var1.p())) {
               zqe var3 = (zqe)this.a.b().get(var1.a("id"));
               var3.a = var2;
               if (this.a.p == null) {
                  this.a.p = new ArrayList();
               }

               com.aspose.cells.b.a.a.ze.a(this.a.p, (Object)var3);
            }
         }

      }
   }

   private void d(zcfw var1) throws Exception {
      WorkbookSettings var2 = this.a.a.getSettings();
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            switch(d.a(var1.p())) {
            case 3:
               var2.setAutoRecover(zase.ax(var1.s()));
               break;
            case 4:
               var2.setCrashSave(zase.ax(var1.s()));
               break;
            case 5:
               var2.setDataExtractLoad(zase.ax(var1.s()));
               break;
            case 6:
               var2.setRepairLoad(zase.ax(var1.s()));
            }
         }
      }

      var1.a();
   }

   private void e(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         for(; zass.a(var1); var1.a()) {
            if ("customWorkbookView".equals(var1.p()) && var1.m()) {
               znd var2 = new znd();
               this.a.a.getWorksheets().k().a(var2);

               while(var1.l()) {
                  int var3;
                  switch(d.a(var1.p())) {
                  case 7:
                     var2.j = var1.s();
                     break;
                  case 8:
                     var2.b = new com.aspose.cells.b.a.zh(var1.s().substring(1, 1 + (var1.s().length() - 2)));
                     break;
                  case 9:
                     var3 = (int)(zase.D(var1.s()) & 4294967295L);
                     if (var3 > 0) {
                        var2.a = var3;
                     }
                     break;
                  case 10:
                     var3 = zase.C(var1.s());
                     if (var3 < 0) {
                        var3 = 0;
                     }

                     var2.c = var3;
                     break;
                  case 11:
                     var2.d = zase.C(var1.s());
                     break;
                  case 12:
                     var2.e = zase.C(var1.s());
                     break;
                  case 13:
                     var2.f = zase.C(var1.s());
                     break;
                  case 14:
                     var2.i = zase.C(var1.s());
                     break;
                  case 15:
                     var2.k(zase.ax(var1.s()));
                     break;
                  case 16:
                     var2.m(zase.ax(var1.s()));
                     break;
                  case 17:
                     var2.h(zase.ax(var1.s()));
                     break;
                  case 18:
                     var2.i(zase.ax(var1.s()));
                     break;
                  case 19:
                     var2.f(zase.ax(var1.s()));
                     break;
                  case 20:
                     var2.e(zase.ax(var1.s()));
                     break;
                  case 21:
                     var2.l(zase.ax(var1.s()));
                     break;
                  case 22:
                     var2.j(zase.ax(var1.s()));
                     break;
                  case 23:
                     var2.a(zase.ax(var1.s()));
                     break;
                  case 24:
                     var2.n(zase.ax(var1.s()));
                     break;
                  case 25:
                     var2.c(zase.ax(var1.s()));
                     break;
                  case 26:
                     var2.d(zase.ax(var1.s()));
                     break;
                  case 27:
                     var2.b(zase.ax(var1.s()));
                     break;
                  case 28:
                     var2.h = zase.C(var1.s());
                     break;
                  case 29:
                     switch(d.a(var1.s())) {
                     case 31:
                        var2.a(2);
                        continue;
                     case 32:
                        var2.a(1);
                     default:
                        continue;
                     }
                  case 30:
                     switch(d.a(var1.s())) {
                     case 33:
                        var2.b(1);
                        break;
                     case 34:
                        var2.b(2);
                     }
                  }
               }

               var1.k();
            }
         }

      }
   }

   private void f(zcfw var1) throws Exception {
      if (var1.m()) {
         Workbook var2 = this.a.a;

         while(var1.l()) {
            switch(d.a(var1.p())) {
            case 35:
               if ("1".equals(var1.s())) {
                  var2.getSettings().m().setEmbedSmartTags(true);
               }
               break;
            case 36:
               switch(d.a(var1.s())) {
               case 33:
                  var2.getSettings().m().setShowType(2);
                  break;
               case 37:
                  var2.getSettings().m().setShowType(0);
                  break;
               case 38:
                  var2.getSettings().m().setShowType(1);
               }
            }
         }

         var1.k();
      }

      var1.a();
   }

   private void g(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if (var1.r() != 1) {
                  var1.a();
               } else {
                  if ("smartTagType".equals(var1.p()) && var1.m()) {
                     String var2 = null;
                     String var3 = null;
                     String var4 = null;

                     while(var1.l()) {
                        switch(d.a(var1.p())) {
                        case 7:
                           var3 = var1.s();
                           break;
                        case 39:
                           var2 = var1.s();
                           break;
                        case 40:
                           var4 = var1.s();
                        }
                     }

                     var1.k();
                     if (var2 != null && var3 != null) {
                        this.a.a.getWorksheets().aa().a(var2, var3, var4);
                     }
                  }

                  var1.a();
               }
            }

            var1.h();
            return;
         }
      }
   }

   private void h(zcfw var1) throws Exception {
      if (var1.m()) {
         WorksheetCollection var2 = this.a.a.getWorksheets();

         try {
            while(var1.l()) {
               if ("calcMode".equals(var1.p())) {
                  this.a.a.getSettings().setCalcMode(zase.au(var1.s()));
               } else if ("fullPrecision".equals(var1.p())) {
                  var2.n().getSettings().setPrecisionAsDisplayed(!zase.ax(var1.s()));
               } else if ("calcOnSave".equals(var1.p())) {
                  this.a.a.getSettings().setRecalculateBeforeSave(zase.ax(var1.s()));
               } else if ("fullCalcOnLoad".equals(var1.p())) {
                  this.a.a.getSettings().setReCalculateOnOpen(zase.ax(var1.s()));
               } else if ("iterate".equals(var1.p())) {
                  this.a.a.getSettings().setIteration(zase.ax(var1.s()));
               } else if ("iterateCount".equals(var1.p())) {
                  this.a.a.getSettings().setMaxIteration(zase.C(var1.s()));
               } else if ("iterateDelta".equals(var1.p())) {
                  this.a.a.getSettings().setMaxChange(zase.B(var1.s()));
               } else if ("refMode".equals(var1.p())) {
                  this.a.a.getSettings().a("R1C1".equals(var1.s()));
               } else if ("calcId".equals(var1.p())) {
                  this.a.a.getSettings().f = zase.C(var1.s());
               }
            }
         } catch (Exception var4) {
            ;
         }

         var1.k();
      }

      var1.a();
   }

   private void i(zcfw var1) throws Exception {
      if (var1.m()) {
         WorksheetCollection var2 = this.a.a.getWorksheets();
         zbvh var3 = var2.N();

         while(var1.l()) {
            if ("workbookPassword".equals(var1.p())) {
               var3.a().a(com.aspose.cells.b.a.zo.a(var1.s(), 515, com.aspose.cells.b.a.c.za.b()));
            } else if ("lockStructure".equals(var1.p())) {
               var3.b = zase.ax(var1.s());
            } else if ("lockWindows".equals(var1.p())) {
               var3.a = zase.ax(var1.s());
            } else if ("workbookAlgorithmName".equals(var1.p())) {
               var3.a().a = var1.s();
            } else if ("workbookHashValue".equals(var1.p())) {
               var3.a().b = com.aspose.cells.b.a.ze.b(var1.s());
            } else if ("workbookSaltValue".equals(var1.p())) {
               var3.a().c = com.aspose.cells.b.a.ze.b(var1.s());
            } else if ("workbookSpinCount".equals(var1.p())) {
               var3.a().d = zase.C(var1.s());
            }
         }

         var1.k();
      }

      var1.a();
   }

   void b(zcfw var1) throws Exception {
      this.r(var1);
      if (!var1.n()) {
         var1.d();

         while(zass.a(var1)) {
            if ("externalReferences".equals(var1.p())) {
               this.l(var1);
            } else {
               var1.a();
            }
         }

         this.a.a.getWorksheets().setActiveSheetIndex(this.b);
      }
   }

   private void j(zcfw var1) throws Exception {
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("readOnlyRecommended".equals(var1.p())) {
               if ("1".equals(var1.s())) {
                  this.a.a.getSettings().setRecommendReadOnly(true);
               }
            } else if ("reservationPassword".equals(var1.p()) && !"0".equals(var1.s())) {
               this.a.a.getSettings().a(com.aspose.cells.b.a.ze.b(var1.s(), 16));
            }
         }
      }

      var1.a();
   }

   private void k(zcfw var1) throws Exception {
      if (var1.m()) {
         zpl var2 = new zpl(false);

         while(var1.l()) {
            if ("appName".equals(var1.p())) {
               var2.a = var1.s();
            } else if ("lastEdited".equals(var1.p())) {
               var2.b = var1.s();
            } else if ("lowestEdited".equals(var1.p())) {
               var2.c = var1.s();
            } else if ("rupBuild".equals(var1.p())) {
               var2.d = var1.s();
            } else if ("codeName".equals(var1.p())) {
               var2.e = var1.s();
            }
         }

         var1.k();
         this.a.a.getSettings().a(var2);
      }

      var1.a();
   }

   private void l(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            if ("externalReference".equals(var1.p())) {
               zpo var2 = new zpo();
               String var3 = var1.a("id", (String)null);
               HashMap var4 = this.a.b();
               if (!var4.containsKey(var3)) {
                  throw new CellsException(6, "externalReference rid " + var3 + " not found in workbook rels file");
               }

               zqe var5 = (zqe)var4.get(var3);
               var2.a = var5.e;
               com.aspose.cells.b.a.a.ze.a(this.a.q, (Object)var2);
               var1.a();
            } else {
               var1.a();
            }
         }

      }
   }

   private void m(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("pivotCache".equals(var1.p())) {
               zqc var2 = new zqc((zauk)null);
               var2.c = var1.a("cacheId");
               String var3 = var1.a("id", (String)null);
               HashMap var4 = this.a.a();
               if (!var4.containsKey(var3)) {
                  throw new CellsException(6, "pivotCache rid " + var3 + " not found in workbook rels file");
               }

               var2.e = var3;
               com.aspose.cells.b.a.a.ze.a(this.a.h, (Object)var2);
               var1.a();
            } else {
               var1.a();
            }
         }

         var1.h();
      }
   }

   private void n(zcfw var1) throws Exception {
      if (var1.m()) {
         zpd var2 = this.a.a.b.i;

         while(true) {
            while(var1.l()) {
               if ("codeName".equals(var1.p())) {
                  this.a.a.getWorksheets().a(var1.s());
               } else if ("defaultThemeVersion".equals(var1.p())) {
                  var2.d = var1.s();
               } else if ("filterPrivacy".equals(var1.p())) {
                  this.a.a.getSettings().setRemovePersonalInformation(zase.ax(var1.s()));
               } else if ("hidePivotFieldList".equals(var1.p()) && "1".equals(var1.s())) {
                  this.a.a.getSettings().setHidePivotFieldList(true);
               } else if ("refreshAllConnections".equals(var1.p())) {
                  if ("1".equals(var1.s())) {
                     this.a.a.getWorksheets().setRefreshAllConnections(true);
                  }
               } else if ("updateLinks".equals(var1.p())) {
                  this.a.a.getSettings().setUpdateLinksType(zase.aw(var1.s()));
               } else if ("publishItems".equals(var1.p())) {
                  var2.e = zase.ax(var1.s());
               } else if ("date1904".equals(var1.p())) {
                  this.a.a.getSettings().setDate1904(zase.ax(var1.s()));
               } else if ("autoCompressPictures".equals(var1.p())) {
                  this.a.a.getSettings().setAutoCompressPictures(zase.ax(var1.s()));
               }
            }

            var1.k();
            break;
         }
      }

      var1.a();
   }

   private void o(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               if (var1.r() == 4) {
                  break;
               }

               var1.a();
            } else if ("workbookView".equals(var1.p())) {
               if (var1.m()) {
                  while(true) {
                     while(var1.l()) {
                        if ("activeTab".equals(var1.p())) {
                           this.b = zase.C(var1.s());
                        } else if ("firstSheet".equals(var1.p())) {
                           this.a.a.getWorksheets().l(zase.C(var1.s()));
                        } else if ("showHorizontalScroll".equals(var1.p()) && "0".equals(var1.s())) {
                           this.a.a.getSettings().setVScrollBarVisible(false);
                        } else if ("showVerticalScroll".equals(var1.p()) && "0".equals(var1.s())) {
                           this.a.a.getSettings().setVScrollBarVisible(false);
                        } else if ("showSheetTabs".equals(var1.p()) && "0".equals(var1.s())) {
                           this.a.a.getSettings().setShowTabs(false);
                        } else if ("minimized".equals(var1.p()) && "1".equals(var1.s())) {
                           this.a.a.getSettings().setMinimized(true);
                        } else if ("visibility".equals(var1.p())) {
                           if ("hidden".equals(var1.s())) {
                              this.a.a.getSettings().setHidden(true);
                           } else if ("veryHidden".equals(var1.s())) {
                              this.a.a.getSettings().setHidden(true);
                           }
                        } else if ("tabRatio".equals(var1.p())) {
                           this.a.a.getSettings().setSheetTabBarWidth(zase.C(var1.s()));
                        } else if ("windowHeight".equals(var1.p())) {
                           this.a.a.getSettings().e(zase.C(var1.s()));
                        } else if ("windowWidth".equals(var1.p())) {
                           this.a.a.getSettings().d(zase.C(var1.s()));
                        } else if ("xWindow".equals(var1.p())) {
                           this.a.a.getSettings().b(zase.C(var1.s()));
                        } else if ("yWindow".equals(var1.p())) {
                           this.a.a.getSettings().c(zase.C(var1.s()));
                        }
                     }

                     var1.k();
                     break;
                  }
               }

               var1.a();
            }
         }

         var1.h();
      }
   }

   private void p(zcfw var1) throws Exception {
      this.a.a.getWorksheets().clear();
      if (var1.n()) {
         var1.a();
      } else {
         int var2 = 0;
         zhu.c();
         int var3 = 0;
         var1.d();

         while(true) {
            label63:
            do {
               while(var1.r() != 4) {
                  var1.j();
                  if (var1.r() == 1) {
                     continue label63;
                  }

                  var1.a();
               }

               this.a.a.getWorksheets().b = var2;
               this.a.a.getWorksheets().q().a(this.a.a.getWorksheets().u());
               var1.h();
               return;
            } while(!"sheet".equals(var1.p()));

            if (var1.m()) {
               String var4 = null;
               String var5 = null;
               String var6 = null;
               String var7 = null;
               String var8 = null;

               while(var1.l()) {
                  if ("name".equals(var1.p())) {
                     var4 = var1.s();
                  } else if ("sheetId".equals(var1.p())) {
                     zase.C(var1.s());
                     var5 = var1.s();
                  } else if ("id".equals(var1.p())) {
                     var6 = var1.s();
                  } else if ("type".equals(var1.p())) {
                     var7 = var1.s();
                  } else if ("state".equals(var1.p())) {
                     var8 = var1.s();
                  }
               }

               if (var7 == null || "chartsheet".equals(var7)) {
                  if (var4 == null || var4.length() == 0 || var5 == null) {
                     throw new CellsException(6, "invalid sheet attributes data");
                  }

                  Worksheet var9 = this.a.a.getWorksheets().get(this.a.a.getWorksheets().add());
                  var9.b(var4);
                  var9.g = new zpr(var9);
                  var9.c(zase.C(var5));
                  if (var9.l() > var2) {
                     var2 = var9.l();
                  }

                  if (var8 != null) {
                     if ("hidden".equals(var8)) {
                        var9.a(false, false);
                     } else if ("veryHidden".equals(var8)) {
                        var9.a(false, true);
                     }
                  }

                  this.a.a(var9, var3, var5, var6);
               }

               var1.k();
               ++var3;
            }

            var1.a();
         }
      }
   }

   private void q(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();
         WorksheetCollection var2 = this.a.a.getWorksheets();

         while(true) {
            label67:
            do {
               while(var1.r() != 4) {
                  var1.j();
                  if (var1.r() == 1) {
                     continue label67;
                  }

                  var1.a();
               }

               var2.getNames().a(false);
               var1.h();
               return;
            } while(!"definedName".equals(var1.p()));

            int var3 = -1;
            boolean var4 = false;
            String var5 = null;
            String var6 = null;
            String var7 = null;
            String var8 = null;
            String var9 = null;
            if (var1.m()) {
               while(var1.l()) {
                  if ("name".equals(var1.p())) {
                     var5 = var1.s();
                  } else if ("localSheetId".equals(var1.p())) {
                     if (zapb.b(var1.s())) {
                        var3 = zase.C(var1.s());
                     }
                  } else if ("hidden".equals(var1.p())) {
                     var4 = "1".equals(var1.s());
                  } else if ("publishToServer".equals(var1.p())) {
                     var7 = var1.s();
                  } else if ("workbookParameter".equals(var1.p())) {
                     var8 = var1.s();
                  } else if ("comment".equals(var1.p())) {
                     var9 = var1.s();
                  }
               }

               var1.k();
            }

            var6 = var1.i();
            if (var5 == null || var6 == null) {
               throw new CellsException(6, "Invalid name data");
            }

            String var10 = var5.toUpperCase();
            boolean var11 = var10.startsWith("_XLNM.");
            if (var11) {
               var5 = var5.substring(6);
               var10 = var5.toUpperCase(com.aspose.cells.b.a.c.za.b().h());
            }

            if (var3 != -1) {
               var3 = this.a.a(var3).getIndex();
            }

            int var12 = var2.getNames().a(var3, var5);
            Name var13 = var2.getNames().get(var12);
            var13.setComment(var9);
            if (var11) {
               var13.f(var10);
            }

            var13.c = "=" + var6;
            var13.a(var4);
            if (var7 != null || var8 != null) {
               var13.a = new zpm();
               var13.a.a = var8;
               var13.a.b = var7;
            }
         }
      }
   }

   private void r(zcfw var1) throws Exception {
      var1.a(0);
      var1.j();
      if (var1.r() != 1 || !"workbook".equals(var1.p())) {
         throw new CellsException(6, "workbook root element eror");
      }
   }
}
